/*******************************************************************************
 * Copyright 2011 WaTho
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package de.wathoserver.android.dragoid.activity.tabs;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.widget.EditText;
import de.wathoserver.android.dragoid.R;
import de.wathoserver.android.dragoid.api.DragoApi;
import de.wathoserver.android.dragoid.util.DialogHelper;
import de.wathoserver.android.dragoid.util.UrlParsingActivity;
import de.wathoserver.android.dragoid.util.UrlParsingTask;

/**
 * Zeigt die Notizen an. (Reiter N)
 * 
 * @author watho
 * 
 */
public class NoticeActivity extends Activity implements
		UrlParsingActivity<CharSequence> {
	private EditText text;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.noticeview);
		text = (EditText) findViewById(R.id.notice);
		reload();
	}

	@Override
	public void reload() {
		new UrlParsingTask<CharSequence>(this, this).execute();
	}

	@Override
	public CharSequence fetchData() throws IllegalAccessException {
		return DragoApi.getApi().getNotice();
	}

	@Override
	public void onSuccess(CharSequence result) {
		text.setText(result);
	}

	@Override
	protected Dialog onCreateDialog(int id) {
		return DialogHelper.createDialogById(this, DIALOG_PROGRESS);
	}

	@Override
	public Activity getUserInfoActivity() {
		return this.getParent();
	}
}
